{include file="common/header" /}

<style>
    .icon{
        float: left;
        display: inline-block;
        margin-top: -35px;
        margin-left: 10px;
        font-size: 30px;
    }
</style>
<div class="layui-container">
    <div class="layui-row">
        <form class="layui-form layui-form-pane" action="" style="margin-top: 20px;">

            {eq name="Think.get.type" value="update"}
            <input type="hidden" name="powerid" value="{$id}"/>
            {/eq}

            <div class="layui-form-item">
                <label class="layui-form-label">名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="powername" required lay-verify="required" placeholder="节点名称" autocomplete="off" class="layui-input" {eq name="Think.get.type" value="update" } value="{$info.powername}" {/eq} />


                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">栏目</label>
                <div class="layui-input-inline">
                    <select name="columnid" lay-verify="required">
                            <option>请选择上级节点</option>

                        {volist name="nodeTree" id="vo"}
                            <option value="{$vo.powerid}" {if condition="$parentId eq $vo['powerid']" } selected {/if} >{$vo.powername}</option>
                        {/volist}

                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">控制器</label>
                <div class="layui-input-inline">
                    <input type="text" name="controller" autocomplete="off" class="layui-input" {eq
                           name="Think.get.type" value="update" } value="{$info.controller}" {/eq}>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">图标</label>
                <div class="layui-input-inline">

                    <input type="input" id="class" class="layui-input" />
                    <input type="hidden" name="class" id="class0" class="layui-input" {eq name="Think.get.type" value="update" } value="{$info.class}"{/eq} />
                    <span class='icon iconfont code' >{eq name="Think.get.type" value="update" }{$info.class}{/eq}</span>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-inline">
                    <select name="type" lay-verify="required">
                        <option value="2" {if condition="($Think.get.type eq 'update') && ($info['type'] eq 2)" } selected {/if}>方法</option>
                        <option value="1" {if condition="($Think.get.type eq 'update') && ($info['type'] eq 1)" } selected {/if}>菜单</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <select name="status" lay-verify="required">
                        <option value="0" {if condition="($Think.get.type eq 'update') && ($info['status'] eq 0)" }
                                selected {/if}>正常</option>
                        <option value="1" {if condition="($Think.get.type eq 'update') && ($info['status'] eq 1)" }
                                selected {/if}>禁用</option>
                    </select>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">权重</label>
                <div class="layui-input-inline">
                    <input type="text" name="weight" required lay-verify="required" autocomplete="off"
                           class="layui-input" {eq name="Think.get.type" value="update" } value="{$info.weight}" {else
                    /} value=0{/eq} />

                </div>
            </div>

            <div class="layui-form-item layui-form-text" style="width:300px">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea name="describe" placeholder="对节点的描述" class="layui-textarea">{eq name="Think.get.type" value="update"}{$info.describe}{/eq}</textarea>
                </div>
            </div>

            <div class="layui-form-item" style="margin-left: -45px;">
                <div class="layui-input-block">
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
                </div>
            </div>
        </form>
    </div>
</div>


<script>
    layui.use(['jquery', 'form','layer'], function () {
        var form = layui.form,
            $ = layui.jquery,
            layer = layui.layer;

        $('#class').click(function () {
            layer.open({
                type: 2,
                title: '选择图标',
                area: ['100%','75%'],
                content: '{:url("Node/icon")}',
            });
        });

        //监听提交
        form.on('submit(formDemo)', function (data) {

            $.post('{:url("Node/save")}', data.field, function (e) {
                layer.msg(e.msg);

                if (e.status == 200) {
                    window.setTimeout(function () {
                        parent.reload();
                        parent.layer.closeAll();
                    }, 500);
                }
            });
            return false;
        });
    });

    function getIcon(name){
        layui.jquery('#class0').val(name);
        layui.jquery('.code').html(name);
    }
</script>
{include file="common/footer" /}